package com.dms.controller;

import com.dms.service.OtherManageService;
import com.dms.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @className: OtherManageController
 * @package: com.dms.controller
 * @description 一些其他需要调用后台的功能控制层
 * @author: sk
 */
@Controller
@RequestMapping("/otherManageController")
public class OtherManageController {

    @Autowired
    OtherManageService otherManageService;


    /**
     * 根据用户类型获取菜单栏
     * @param userType
     * @return
     */
    @GetMapping("/getMenuList")
    @ResponseBody
    public Msg getMenuList(@RequestParam("userType") Integer userType){
        return Msg.success().add("menuList",otherManageService.getMenuList(userType));
    }

    /**
     * 修改密码
     * @param userName
     * @param password
     * @return
     */
    @PutMapping("/editPassword/{userName}/{password}")
    @ResponseBody
    public Msg editPassword(@PathVariable("userName") String userName, @PathVariable("password") String password){
        return otherManageService.editPassword(userName, password) > 0 ? Msg.success() : Msg.fail();
    }

}
